using ThoughtWorks.CruiseControl.Core.Tasks;
using ThoughtWorks.CruiseControl.Core.Tasks.Conditions;
using Exortech.NetReflector;
using ThoughtWorks.CruiseControl.Core;

namespace ThoughtWorks.CruiseControl.UnitTests.Core.Tasks.Conditions
{
    [ReflectorType("mock")]
    public class TaskConditionMock : ITaskCondition
    {
        public TaskConditionMock()
        {
            MockResult = false;
        }

        public TaskConditionMock(bool mockResult)
        {
            MockResult = mockResult;
        }

        [ReflectorProperty("result", Required = true)]
        public bool MockResult { get; set; }

        #region ITaskCondition Members

        public bool Eval(IIntegrationResult result)
        {
            return MockResult;
        }

        #endregion

        public static ITaskCondition[] GetMockConditions(bool[] results)
        {
            ITaskCondition[] conditions;
            conditions = new ITaskCondition[results.Length];
            int offset = 0;
            foreach (bool subResult in results)
            {
                conditions[offset] = new TaskConditionMock(subResult);
                offset++;
            }
            return conditions;
        }
    }
}